import unittest
import math
#import decimal
from decimal import *

from MatrixUtils import *

class MatrixUtilsTests(unittest.TestCase):
   
    def testRotate(self):
        matrix = [1, 0]
        matrix2 = MatrixUtils.rotateMatrix(matrix, math.pi *2)
        print matrix2
        #string0 = str(matrix2[0])
        #string1 = str(matrix2[1])
        zero = abs(Decimal(str(matrix2[0])).quantize(Decimal('0')))
        one = abs(Decimal(str(matrix2[1])).quantize(Decimal('0')))
        matrix3 = [zero, one]
        
        print "zero: ", zero
        print "one: ", one
        self.failUnless(MatrixUtils.rotateMatrix(matrix3, 90) == [0,1])
    
    def testAddMatrix(self):
        matrix1 = [1, 0]
        matrix2 = [0, 2]
        matrix3 = MatrixUtils.addMatrix(matrix1, matrix2)
        print matrix3
        self.failUnless(matrix3 == [1,2])
    
    def testMultiplyMatrix(self):
        matrix1 = [1, 2]
        multiplyBy = 3
        matrix2 = MatrixUtils.multiplyMatrix(multiplyBy, matrix1)
        print matrix2
        self.failUnless(matrix2 == [3,6])


def main():
    unittest.main()

if __name__ == '__main__':
    main()
